Third-Party Services Integration
FF-API-External integrates with numerous third-party services to provide a comprehensive API platform. This document details the various services integrated, how they are configured, and how they are used within the application.
Table of Contents
- AI Services
- Vehicle Information Services
- Mobile Device Information
- Search and SERP Services
- Location Services
- Payment Services
- Communication Services
- Other Services
AI Services
OpenAI (ChatGPT)
OpenAI's ChatGPT API is integrated to provide AI-powered text generation, product matching, and specifications extraction.
Configuration:
# OpenAI API key from .env
CHAT_GPT_API_KEY = config('CHAT_GPT_API_KEY')
Usage Example:
class ChatGPT:
def __init__(self):
self.api_key = config('CHAT_GPT_API_KEY')
self.client = OpenAI(api_key=self.api_key)
def generate_response(self, prompt, full=False, model="gpt-4o", temperature=0.7, max_tokens=2048, top_p=1.0, frequency_penalty=0.0, presence_penalty=0.0):
# Generate a response using the OpenAI API
response = self.client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
temperature=temperature,
max_tokens=max_tokens,
top_p=top_p,
frequency_penalty=frequency_penalty,
presence_penalty=presence_penalty
)
# Return full response or just the content
if full:
return {"prompt": prompt, "response": response}
return response.choices[0].message.content
Anthropic (Claude)
Anthropic's Claude API is integrated for an alternative AI model with different capabilities.
Configuration:
# Anthropic API key from .env
CLAUDE_API_KEY = config('CLAUDE_API_KEY')
Usage Example:
class ClaudeAI:
def __init__(self):
self.api_key = config('CLAUDE_API_KEY')
self.client = anthropic.Anthropic(api_key=self.api_key)
self.available_models = {
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
"claude-3-5-sonnet-20240620",
"claude-3-7-sonnet-20250219"
}
def generate_response(self, prompt, max_tokens=1000, temperature=0.7, system_prompt=None):
# Set default system prompt if none provided
if not system_prompt:
system_prompt = "You are Claude, an AI assistant created by Anthropic."
# Generate a response using the Claude API
response = self.client.messages.create(
model="claude-3-7-sonnet-20250219",
max_tokens=max_tokens,
temperature=temperature,
system=system_prompt,
messages=[{"role": "user", "content": prompt}]
)
return response.content[0].text
Vehicle Information Services
Car API
The Car API provides detailed information about vehicles, including makes, models, trims, and specifications.
Configuration:
# CarAPI credentials from .env
CARAPI_TOKEN = config('CARAPI_TOKEN')
CARAPI_SECRET = config('CARAPI_SECRET')
Usage Example:
class CarAPI:
def __init__(self, base_url, api_token, api_secret):
self.base_url = base_url
self.api_token = api_token
self.api_secret = api_secret
self.headers = {
"Authorization": f"Bearer {self.api_token}:{self.api_secret}"
}
def search_makes(self, **params):
"""Search for vehicle makes with optional filtering."""
return self._make_request("get", "/api/makes", params)
Vehicle API
The Vehicle API (VAPI) provides hierarchical vehicle data like years, makes, models, trims, etc.
Configuration:
# Vehicle API key from .env
VEHICLE_API_KEY = config('VEHICLE_API_KEY')
Usage Example:
class VApi:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = "https://vehapi.com/api/v1"
self.headers = {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
'Authorization': self.api_key
}
def get_all_years(self):
"""Get a list of all vehicle years."""
url = f"{self.base_url}/car-lists/get/car/years"
response = requests.get(url, headers=self.headers)
return response.json()
VIN Decoder
The Vincario VIN Decoder API is used to decode Vehicle Identification Numbers and retrieve detailed vehicle information.
Configuration:
# VIN Decoder API credentials from .env
VINDECODER_API_KEY = config('VINDECODER_API_KEY')
VINDECODER_SECRET_KEY = config('VINDECODER_SECRET_KEY')
Usage Example:
class VincarioVINDecoder:
def __init__(self, api_key, secret_key):
self.api_key = api_key
self.secret_key = secret_key
self.base_url = "https://api.vindecoder.eu/3.0"
def decode(self, vin):
"""Decode a VIN and return detailed vehicle information."""
url = f"{self.base_url}/{self.api_key}/{self.secret_key}/decode/{vin}.json"
response = requests.get(url)
return response.json()
Vehicle Database
The Vehicle Database API provides comprehensive vehicle information.
Configuration:
# Vehicle Database API key from .env
VDB_API_KEY = config('VDB_API_KEY')
Usage Example:
class VehicleDatabase:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = "https://api.vehicledatabase.net/vehicle"
self.headers = {
"X-API-KEY": self.api_key,
"Content-Type": "application/json"
}
def vin_decode(self, vin):
"""Decode a VIN and return vehicle details."""
url = f"{self.base_url}/vin_decode/{vin}"
response = requests.get(url, headers=self.headers)
return response.json()